﻿using MediatR;
using S.EarTag.API.Mediator.MediatorCommand.AppearanceCommand;
using S.EarTag.Infrastructure.Repository.Interface.IEarTagRepository;

namespace S.EarTag.API.Mediator.MediatorCommandHandler.AppearanceCommandHandler
{
    public class AppearanceCreateCommandHandler : IRequestHandler<AppearanceCreateCommand, bool>
    {
        private readonly IAppearanceModelRepository _appearanceModelRepository;
        public AppearanceCreateCommandHandler(IAppearanceModelRepository appearanceModelRepository)
        {
            _appearanceModelRepository= appearanceModelRepository;
        }
        /// <summary>
        /// 添加品相测量数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<bool> Handle(AppearanceCreateCommand request, CancellationToken cancellationToken)
        {
            return await _appearanceModelRepository.AddAsync(new Domain.Model.AppearanceModel
            {
                MeasureDate= request.MeasureDate,
                EarTag = request.EarTag,
                Tooth=request.Tooth,
                Hair=request.Hair,
                Stain=request.Stain,
                HoofColor=request.HoofColor,
                MouthColor=request.MouthColor,
                Angle=request.Angle,
                FatDistribution=request.FatDistribution,
                CreateBy=request.CreateBy,
                CreateDate=request.CreateDate,
                UpdateBy=request.UpdateBy,
                UpdateDate=request.UpdateDate,
            });
        }
    }
}
